<template>
    <el-dialog
            title="注册"
            :close-on-click-modal="false"
            :visible.sync="dialogVisible"
            width="30%">
        <el-form ref="form" label-width="120px" :model="form" :rules="rules" class="demo-ruleForm">
            <el-col :span="24">
                <el-form-item label="帐号：" prop="username">
                    <el-input v-model="form.username" type="text" maxlength="11" placeholder="请输入"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="24">
                <el-form-item label="密码：" prop="password">
                    <el-input v-model="form.password" type="password" maxlength="11" placeholder="请输入"></el-input>
                </el-form-item>
            </el-col>
            <el-col :span="24">
                <el-form-item label="确认密码：" prop="confirmPassword">
                    <el-input v-model="form.confirmPassword" type="password" maxlength="11" placeholder="请输入"></el-input>
                </el-form-item>
            </el-col>
        </el-form>

        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible2 = false">取 消</el-button>
            <el-button type="primary" @click="register">注 册</el-button>
          </span>
    </el-dialog>
</template>

<script>
    export default {
        name: "registerDia",
        data(){
            return{
                dialogVisible: false,
                form: {
                    username: '',
                    password: '',
                    confirmPassword: '',
                },
                rules: {
                    username: [{required: true, message: '请输入', trigger: 'blur'}],
                    password: [{required: true, message: '请输入', trigger: 'blur'}],
                    confirmPassword: [{required: true, message: '请输入', trigger: 'blur'}],
                }
            }
        },
        methods:{
            //打开弹框
            openDia(){
                this.dialogVisible=true;
            },


            register() {
                this.$refs['form'].validate((valid) => {
                    if (valid) {
                        //调用注册接口
                        this.$HttpService.post("/sys-login/register",this.form).then(res=>{
                            this.$message.success('注册成功！请登录');
                            this.dialogVisible=false;
                        })
                    }
                })
            },
        }
    }
</script>

<style scoped>

</style>
